<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>login</title>
</head>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript'>
	function iteratorTags(){
		var params="max=5&first=0";
		new Ajax.Request("json/iteratorTags", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				document.getElementById("tagDisplayer").innerHTML = "热门检索标签：";
				var res = request.responseText.evalJSON();
				for(var i=0;null!=res["result"]["product_tagName"+i];i++)
					document.getElementById("tagDisplayer").innerHTML+=
						"<a href='viewOneTag.html?tagNameId="+res["result"]['product_tagNameId'+i]+"'>"
						+res["result"]["product_tagName"+i]
						+"</a>&nbsp;";
			},
			asynchronous : true
		});
	}
	function online() {
		var params = "";
		new Ajax.Request("json/online", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();
				document.getElementById("online").innerHTML = "当前在线人数："
						+ res["result"]["online"];
			},
			asynchronous : true
		});
		iteratorTags();
	}
	function login() {
		var visitorName = document.getElementById("visitorName").value;
		var password = hex_sha1(document.getElementById("password").value);
		var params = "visitorName=" + visitorName + "&password=" + password;
		new Ajax.Request("json/login", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();
				if (res["result"]["flag"] == "true") {
					window.location.href = "./productOwner.html";
				} else
					alert("用户名或密码错误！");
			},
			asynchronous : true
		});
	}
</script>
<body onload="online()">
	<div class="topbar">
		<ul class="horizon">
			<li style="margin-left: 50%; margin-top: 2px;" class="logo"><a
				href="login.html">首页</a></li>
			<li class="login" id="login">
				<form method="post">
					<input type="text" id="visitorName" onclick="clear()" value="用户名"
						name="visitorName" /> <input type="password" id="password"
						name="password" /> <input type="button" value="login"
						onclick="login()" />
				</form>
			</li>
		</ul>
	</div>
	<div class="main">
		<ul class="horizon">
			<li>
				<ul class="vertical">
					<li class="managePad">
						<ul class='vertical' style="margin-left: 60px;">
							<li id="online" style="top:80%;position:absolute"></li>
							<li id="tagDisplayer"></li>
						</ul>
					</li>
				</ul>
			<li class="content">
				<ul class="vertical" id="iteratorProductsTarget">
					<li class='register'>
						<form id='register'>
							<ul class='vertical'>
								<li><input type='text' name='userName' value='用户名'
									onclick='clear()' /></li>
								<li><input type='text' name='userPwd' value='密码'
									onclick='clear()' /></li>
								<li><input type='text' name='userPwd1' value='重复密码'
									onclick='clear()' /></li>
								<li><input type='text' name='email' value='邮箱'
									onclick='clear()' /></li>
								<li><input type='text' name='phone' value='手机号'
									onclick='clear()' /></li>
								<li><input type='button' value='注册' onclick="regitstor()" />
								</li>
							</ul>
						</form>
					</li>
				</ul>
		</ul>
	</div>
</body>
</html>